home *** CD-ROM | disk | FTP | other *** search
- Path: cs.uwa.edu.au!jasonb
- From: jasonb@cs.uwa.edu.au (Jason S Birch)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: manipulating the stack in C
- Date: 27 Jan 96 04:50:23 GMT
- Organization: The University of Western Australia
- Message-ID: <jasonb.822718223@cs.uwa.edu.au>
- References: <4e8b20$lsq@newshost.lanl.gov> <Sh++x*aE0@mkmk.in-chemnitz.de>
- NNTP-Posting-Host: decadence.cs.uwa.oz.au
- X-Newsreader: NN version 6.5.0 #3 (NOV)
-
- floh@mkmk.in-chemnitz.de (Andre Weissflog) writes:
- >I think it would be nicer if you give foo() the number of
- >args first, following the args:
-
- >void foo(ULONG num_args,...);
-
- >Since C pushes the last arg first, you will find num_args
- ^^^
- >always at 4(a7), followed by the "real" arguments starting
- >at 8(a7):
-
- I haven't got docs with me right now, but I think you'll find that
- this is compiler-dependent - ANSI C, AFAIR, doesn't define the order
- arguments will be put on the stack, or even, indeed, that they *will*
- be put on the stack (hence SAS/C's registerized parameters option is
- perfectly legal). So, you'll have to keep that in mind, and also find
- out how your particular compiler does it, although all the ones I've
- checked do it the way you suggest (except SAS/C with registerized
- parameters, of course, or when a function is inlined).
-
- Other than that, you're right - the normal way to do it is either put
- some sort of indication of the number as the first parameter (printf()
- looks at the format string to determine the number of arguments) or a
- special flag at the end (eg. TAG_DONE).
-
- >Bye,
- >-Floh.
- >====//=== Andre Weissflog <floh@mkmk.in-chemnitz.de> =======
-
- --
- Jason S Birch ,-_|\ email: jasonb@cs.uwa.edu.au
- Department of Computer Science / \ Tel (work): +61 9 380 1840
- The University of Western Australia *_.-._/ Fax (work): +61 9 380 1089
- Nedlands W. Australia 6907 v Tel (home): +61 9 386 8630
-